package com.atguigu.gmall.product.exception;

import com.atguigu.gmall.common.result.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @ControllerAdvice 这个类是所有异常的统一处理类
 * 全局异常处理器
 */
@RestControllerAdvice
public class MyExceptionHandler {

    @ExceptionHandler(value = {
            ArithmeticException.class
    })
    public Result handleException(Exception e){
        return Result.fail(e.getMessage());

    }
}
